import Taro, { useState, useEffect, useRouter } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { IIndex } from '../../interfaces/index'
import { IMember } from '../../interfaces/member'
import useBasePage from '../basePage/useBasePage'
import { redirectToPage } from '../../utils/index'
import { AtAvatar, AtCard } from 'taro-ui'
import Store from '../../store'
const { fileCdn } = Store as any

const Member = () => {
  const { params } = useRouter()
  const { onload, awtRs } = useBasePage()
  const [ pageTitle, setPageTitle ] = useState<IIndex['pageTitle']>('会员中心')
  const [ userName, setUserName ] = useState<IMember['userName']>('kyan')

  useEffect(() => {
    onload(async () => {
      console.log('参数：', params)
      setUserName('王老菊')
    }, pageTitle)
  }, [])

  return (
    <View className='page page-fixed'>
      <AtAvatar image={ fileCdn + 'img/200' } circle customStyle={ {margin: '0 auto'} } size='large'></AtAvatar>
      <AtCard
        extra={ userName }
        title='欢迎用户：'
      >
        <View onClick={ () => redirectToPage('/pages/member/login') }>去登录</View>
      </AtCard>
    </View>
  )
}

export default Member
